import request from "../utils/request.js";


export const getShceduleListQueryService = (params) => {
    
  return request.get("/air/manager/flightSchedule/page", {params:params});
};

export const getAirportListService = () => {
  return request.get("/air/manager/airport");
};

export const getTicketQueryListService = (params) => {
  return request.get("/air/manager/ticket/page", {params:params});
}

export const createOrderService = (ticketIds) => {
  const formData = new FormData();
  ticketIds.forEach(id => formData.append('ticketIds', id));
  
  return request.post("/air/manager/order/create", formData);
}

export const getTicketByIdService = (id) => {

  return request.get(`/air/manager/ticket/getTicketById/${id}`);
}

export const getOrderByStatusService = (params) => {

  return request.get(`/air/manager/order/getByStatus`, {params:params});
}

export const getOrderDetailByOrderIdService = (orderId) => {

  return request.get(`/air/manager/order/getByOrderId/${orderId}`);
}

export const getDiscountByPointService = (orderId) => {

  let params = new URLSearchParams();
  params.append('orderId', orderId);

  return request.get("/air/manager/discount/getByPoint", {params:params});

}

export const getMemberInfoService = () => {
  return request.get("/air/manager/member");
}

export const registerMemberService = () => {
  return request.post("/air/manager/member");
}

export const createPaymentService = (orderId) => {
  let params = new URLSearchParams();
  params.append('orderId', orderId);
  return request.get("/air/manager/payment/createPayment", {params:params});
}

export const confirmOrderService = (params) => {

  return request.get("/air/manager/order/confirmOrder", {params:params});
}

export const modifyOrderService = (params) => {

  return request.get("/air/manager/order/modify", {params:params});
}

export const cancelOrderService = (params) => {

  return request.get("/air/manager/order/cancel", {params:params});
}


export const getSeatQueryListService = (params) => {
  return request.get("/air/manager/seat/page", {params:params});
}

export const addTicketService = (params) => {
  return request.get(`/air/manager/ticket/add/`, {params:params});
}


export const startOrstopTicketService=(params)=>{

  return request.get("/air/manager/ticket/startOrstop", {params:params});
}

export const  changeScheduleStatusService=(id,status)=>{

  let params = new URLSearchParams();
  params.append('id', id);
  params.append('status', status);

  return request.get("/air/manager/flightSchedule",{params:params});
}

export const  getUsersInPageService = (params) => {

  return request.get("/air/manager/user/getUserByPage", {params:params});
}

export const openOrBanUserService = (userId) => {
  return request.put(`/air/manager/user/openOrBanUser/${userId}`);
}


export const orderStatisticsService = (data) => {

  return request.post("/air/manager/dataStatistics/orderStatistics", data);
}
export const userStatisticsService = (data) => {

  return request.post("/air/manager/dataStatistics/userStatistics", data);
}